//
//  SearchDB.m
//  A段项目音乐播放
//
//  Created by dllo on 15/5/29.
//  Copyright (c) 2015年 lanou3g.com蓝鸥科技. All rights reserved.
//

#import "SearchDB.h"

static sqlite3 *dbPoint = nil;


@implementation SearchDB

+ (sqlite3 *)openDB
{
    if (dbPoint) {
        return dbPoint;
    }
    
    NSArray *array = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
    NSString *path = [array lastObject];
    path = [NSString stringWithFormat:@"%@/@Search.rdb",path];
    
    NSFileManager *manager = [NSFileManager defaultManager];
    if (![manager fileExistsAtPath:path]) {
        NSString *source = [[NSBundle mainBundle]pathForResource:@"Search.rdb" ofType:nil];
        [manager copyItemAtPath:source toPath:path error:nil];
    }
    
    sqlite3_open([path UTF8String], &dbPoint);
    return dbPoint;
}


+ (void)closeDB
{
    sqlite3_close(dbPoint);
}


@end
